<%@ page language="java" import="com.baomidou.mybatisplus.extension.plugins.pagination.Page" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    Page page1 = (Page) session.getAttribute("commentsPage");
    Long pages = (Long) session.getAttribute("commentPages");
    Integer currentPage = 1;
    boolean head = false;
    boolean tail = false;
    if (page1 != null) {
        if (page1.getCurrent() == 1) {
            head = true;
        }
        if (page1.getCurrent() == pages) {
            tail = true;
        }
    }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>新闻中国</title>
    <link href="../../../static/css/main.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../../static/js/jquery-1.12.4.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<table width="100%">
    <c:if test="${empty sessionScope.comments}">
        <tr align="center">暂无评论</tr>
    </c:if>
    <c:if test="${not empty sessionScope.comments}">
        <c:forEach items="${sessionScope.comments}" var="item">
            <tr>
                <td>留言人：</td>
                <td>${item.cauthor}</td>
                <td>IP：</td>
                <td>${item.cip}</td>
                <td>留言时间：</td>
                <td>${item.cdate}</td>

            </tr>
            <tr>
                <td colspan="6">${item.ccontent}</td>
            </tr>
            <tr>
                <td colspan="6">
                    <hr/>
                </td>
            </tr>
        </c:forEach>

    </c:if>
</table>
<c:if test="${not empty sessionScope.comments}">
    <p align="center">
        <span>当前页数:[${sessionScope.commentsPage.current}/${sessionScope.commentPages}]</span>
    </p></p>
    <p align="center">
        <button onclick="selectCommentPage(1)">首页</button>
        <button onclick="selectCommentPage(${sessionScope.commentsPage.current}-1)" <%=head ? "disabled" : ""%>>
            上一页
        </button>
        <button onclick="selectCommentPage(${sessionScope.commentsPage.current}+1)" <%=tail ? "disabled" : ""%>>
            下一页
        </button>
        <button onclick="selectCommentPage(${sessionScope.commentPages})">末页</button>
    </p>
</c:if>
</body>
</html>
